/**
 * 
 */
package org.mspring.mlog.web.module.admin;

import javax.servlet.http.HttpServletRequest;

import org.mspring.mlog.entity.security.User;
import org.mspring.mlog.support.log.Log;
import org.mspring.mlog.web.security.SecurityUtils;
import org.mspring.platform.web.freemarker.widget.stereotype.Widget;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * @author Gao Youbo
 * @since 2012-7-16
 * @Description
 * @TODO
 */
@Widget
@RequestMapping("/admin")
public class Admin_LoginWidget extends AbstractAdminWidget {

    @RequestMapping(value = { "/login" }, method = { RequestMethod.GET })
    @Log
    public String login(@ModelAttribute User user, HttpServletRequest request) {
        User currentUser = SecurityUtils.getCurrentUser(request);
        if (currentUser != null) {
            return "redirect:/admin/index";
        }
        return "/admin/login";
    }
}
